package com.canbot.u05.activity.presidemode.newcode.bean;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.canbot.u05.R;
import com.canbot.u05.activity.agenda.bean.AgendaBean;
import com.canbot.u05.activity.agenda.dao.AgendaDataTable;
import com.canbot.u05.activity.presidemode.HostModeListViewActivity;
import com.canbot.u05.activity.presidemode.eventbus.AudioEvent;
import com.canbot.u05.activity.presidemode.newcode.interfaces.IResponse;
import com.canbot.u05.bean.AppInfo;
import com.canbot.u05.bean.Audio;
import com.canbot.u05.bean.JsonResponse;
import com.canbot.u05.bean.guide.MapInfo;
import com.canbot.u05.bean.sales.SellInfo;
import com.canbot.u05.network.SalesApi;
import com.canbot.u05.socket.IpMsgConst;
import com.canbot.u05.utils.OkHttpUtils;
import com.canbot.u05.utils.PathConst;
import com.canbot.u05.view.UsherModeRecordDialog;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.io.File;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class NetLoadUtil {
    public static final int PRESIDE_SERVLET_TYPE_ADD = 0; //添加一个任务
    public static final int PRESIDE_SERVLET_TYPE_DELETE = 1; // 删除
    public static final int PRESIDE_SERVLET_TYPE_RENAME = 2; // 重命名
    public static final int PRESIDE_SERVLET_TYPE_UPDATE = 3; // 修改
    public static final int PRESIDE_SERVLET_TYPE_QUERY_ALL = 4; // 查询所有
    public static final int PRESIDE_SERVLET_TYPE_TASK_RUN = 5; // 运行
    public static final int PRESIDE_SERVLET_TYPE_TASK_START = 6; // 开始
    public static final int PRESIDE_SERVLET_TYPE_NODE_START = 7; // 开始
    public static final int PRESIDE_SERVLET_TYPE_NODE_STOP = 8;// 停止
    public static final int MAP_TYPE_GET_TASK_LIST = 0;

    /**
     * 获取贵宾引导的所有任务
     *
     * @param context
     * @param iResponse
     */
    public static void loadGBDYTaskList(Context context, IResponse<String> iResponse) {
        HashMap<String, Object> hashMap = new HashMap<String, Object>();
        hashMap.put("vipType", "queryAllRoute");
        OkHttpUtils.post("http://" + IpMsgConst.CHEST_SOCKET_HOST +
                ":7755/" + "routevipGuide", hashMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                JsonResponse jsonResponse = JSON.parseObject(result, JsonResponse.class);
                if (jsonResponse.getRc() == 0) {
                    if (iResponse != null) {
                        iResponse.onSucusse(jsonResponse.getResult().toString());
                    }
                } else {
                    if (iResponse != null) {
                        iResponse.onFailuer(context.getString(R.string.service_error_hint));
                    }
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    /**
     * 获取海报宣传(二维码营销) 的任务列表
     *
     * @param context
     * @param iResponse
     */
    public static void loadCodeMarkerTaskList(Context context, IResponse<String> iResponse) {
        String url = IpMsgConst.HTTP_URL_CHEST + "codeMarketingAction";
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("type", 1);
        OkHttpUtils.post(url, hashMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (TextUtils.isEmpty(result)) {
                    if (iResponse != null) {
                        iResponse.onSucusse(null);
                    }
                    return;
                }
                if (iResponse != null) {
                    iResponse.onSucusse(result);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    /**
     * 迎宾接待任务的获取
     *
     * @param context
     * @param iResponse
     */
    public static void loadReceptionTaskList(Context context, IResponse<String> iResponse) {
        String url = IpMsgConst.HTTP_URL_CHEST + "usherModeAction";
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("type", 8);
        OkHttpUtils.post(url, hashMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (TextUtils.isEmpty(result)) {
                    if (iResponse != null) {
                        iResponse.onSucusse(null);
                    }
                    return;
                }
                if (iResponse != null) {
                    iResponse.onSucusse(result);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    /**
     * 获取地图点
     *
     * @param context
     * @param iResponse
     */
    public static void getMapInfo(Context context, IResponse<MapInfo> iResponse) {
        String url = IpMsgConst.HTTP_URL_CHEST + "guideMapAction";
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("type", MAP_TYPE_GET_TASK_LIST + "");
        hashMap.put("data", 1);
        OkHttpUtils.post(url, hashMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (TextUtils.isEmpty(result)) {
                    if (iResponse != null) {
                        iResponse.onSucusse(null);
                    }
                    return;
                }
                MapInfo mMapInfo = new Gson().fromJson(result, MapInfo.class);
                if (iResponse != null) {
                    iResponse.onSucusse(mMapInfo);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    public static final int TIMEOUT = 15;//超时时间100s

    /**
     * 设置超时
     *
     * @return
     */
    private static OkHttpClient setTimeOut() {
        OkHttpClient client = new OkHttpClient.Builder()
                .connectTimeout(TIMEOUT, TimeUnit.SECONDS)
                .writeTimeout(TIMEOUT, TimeUnit.SECONDS)
                .readTimeout(TIMEOUT, TimeUnit.SECONDS)
                .build();
        return client;
    }

    /**
     * 获取促销揽客任务列表
     *
     * @param context
     * @param iResponse
     */
    public static void loadZXLKTaskList(Context context, IResponse<List<SellInfo>> iResponse) {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("http://" + IpMsgConst.CHEST_SOCKET_HOST + ":7755")
                .addConverterFactory(GsonConverterFactory.create())
                .client(setTimeOut())
                .build();
        SalesApi salesApi = retrofit.create(SalesApi.class);
        Call<List<SellInfo>> allSell = salesApi.getAllSell();
        allSell.enqueue(new Callback<List<SellInfo>>() {
            @Override
            public void onResponse(Call<List<SellInfo>> call, Response<List<SellInfo>> response) {
                if (response.body() != null) {
                    List<SellInfo> body = response.body();
                    if (iResponse != null) {
                        iResponse.onSucusse(body);
                    }
                } else {
                    if (iResponse != null) {
                        iResponse.onFailuer(context.getString(R.string.service_error_hint));
                    }
                }
            }

            @Override
            public void onFailure(Call<List<SellInfo>> call, Throwable t) {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    /**
     * 删除一个日程任务
     *
     * @param context
     * @param iResponse
     */
    public static void deleteAgendaTask(Context context, AgendaDataTable agendaDataTable, IResponse<String> iResponse) {
        HashMap<String, Object> hasMap = new HashMap<>();
        hasMap.put("crud", "delete");
        hasMap.put("data", new Gson().toJson(agendaDataTable));
        OkHttpUtils.post("http://" + IpMsgConst.CHEST_SOCKET_HOST + ":7755/" + "agenda", hasMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (iResponse != null) {
                    iResponse.onSucusse(result);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    /**
     * 获取日程任务（根据日期去获取）
     *
     * @param context
     * @param iResponse
     */
    public static void loadAgendaTask(Context context, long time, IResponse<String> iResponse) {
        HashMap<String, Object> hasMap = new HashMap<>();
        hasMap.put("crud", "getall");
        hasMap.put("data", String.valueOf(time));
        OkHttpUtils.post("http://" + IpMsgConst.CHEST_SOCKET_HOST + ":7755/" + "agenda", hasMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (iResponse != null) {
                    iResponse.onSucusse(result);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    /**
     * 更新一个日程任务
     *
     * @param context
     * @param iResponse
     */
    public static void updateAgendaTask(Context context, IResponse<String> iResponse, AgendaDataTable agendaBean, AgendaDataTable agendaDataTable) {
        HashMap<String, Object> hasMap = new HashMap<>();
        hasMap.put("crud", "update");
        hasMap.put("data", new Gson().toJson(agendaBean));
        if (agendaDataTable != null) {
            hasMap.put("dataold", new Gson().toJson(agendaDataTable));
        }
        OkHttpUtils.post("http://" + IpMsgConst.CHEST_SOCKET_HOST + ":7755/" + "agenda", hasMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (iResponse != null) {
                    iResponse.onSucusse(result);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    /**
     * 上传日程任务
     *
     * @param context
     * @param iResponse
     */
    public static void loadVideoInfo(Context context, IResponse<String> iResponse) {
        HashMap<String, Object> hasMap = new HashMap<>();
        hasMap.put("crud", "getVideo");
        OkHttpUtils.post("http://" + IpMsgConst.CHEST_SOCKET_HOST + ":7755/" + "agenda", hasMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (iResponse != null) {
                    iResponse.onSucusse(result);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    /**
     * 获取配置的App信息
     *
     * @param context
     * @param iResponse
     */
    public static void getAppInfos(Context context, IResponse<String> iResponse) {
        HashMap<String, Object> hasMap = new HashMap<>();
        hasMap.put("get_data", "get_data");
        OkHttpUtils.upLoadFile("http://" + IpMsgConst.CHEST_SOCKET_HOST + ":7755/" + "appInfo", hasMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                final JsonResponse strMsgBean = JSON.parseObject(result, JsonResponse.class);
                if (strMsgBean.getRc() == 0) {
                    if (iResponse != null) {
                        iResponse.onSucusse(strMsgBean.getResult().toString());
                    }
                } else {
                    if (iResponse != null) {
                        iResponse.onFailuer(context.getString(R.string.service_error_hint));
                    }
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    /**
     * 上传日程任务
     *
     * @param context
     * @param iResponse
     */
    public static void loadMusicInfo(Context context, IResponse<String> iResponse) {
        HashMap<String, Object> hasMap = new HashMap<>();
        hasMap.put("crud", "getMusic");
        OkHttpUtils.post("http://" + IpMsgConst.CHEST_SOCKET_HOST + ":7755/" + "agenda", hasMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (iResponse != null) {
                    iResponse.onSucusse(result);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    /**
     * 上传日程任务
     *
     * @param context
     * @param iResponse
     */
    public static void addAgendaTask(Context context, IResponse<String> iResponse, AgendaBean agendaBean, AgendaDataTable agendaDataTable) {
        HashMap<String, Object> hasMap = new HashMap<>();
        hasMap.put("crud", "add");
        hasMap.put("data", new Gson().toJson(agendaBean));
        if (agendaDataTable != null) {
            hasMap.put("dataold", new Gson().toJson(agendaDataTable));
        }
        OkHttpUtils.post("http://" + IpMsgConst.CHEST_SOCKET_HOST + ":7755/" + "agenda", hasMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (iResponse != null) {
                    iResponse.onSucusse(result);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    public static void handTaskStart(Context context, IResponse<String> iResponse, HostModuleData hostModuleData) {
        final String toJSONString = JSON.toJSONString(hostModuleData);
        HashMap<String, Object> hasMap = new HashMap<>();
        hasMap.put("type", PRESIDE_SERVLET_TYPE_TASK_START);
        hasMap.put("data", toJSONString);
        OkHttpUtils.post("http://" + IpMsgConst.CHEST_SOCKET_HOST + ":7755/" + "presenterNewMsg", hasMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (iResponse != null) {
                    iResponse.onSucusse(result);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    public static void exeNodeTask(Context context, IResponse<String> iResponse, final int runType, final Object data) {
        HashMap<String, Object> hasMap = new HashMap<>();
        hasMap.put("type", HostModeListViewActivity.PRESIDE_SERVLET_TYPE_TASK_RUN);
        hasMap.put("runType", runType);
        hasMap.put("data", data);
        OkHttpUtils.post("http://" + IpMsgConst.CHEST_SOCKET_HOST + ":7755/" + "presenterNewMsg", hasMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (iResponse != null) {
                    iResponse.onSucusse(result);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    public static void addTaskData(Context context, IResponse<String> iResponse, HostModuleData hostModuleData) {
        saveTaskData(context, iResponse, hostModuleData, PRESIDE_SERVLET_TYPE_ADD);
    }

    public static void updateTaskData(Context context, IResponse<String> iResponse, HostModuleData hostModuleData) {
        saveTaskData(context, iResponse, hostModuleData, PRESIDE_SERVLET_TYPE_UPDATE);
    }

    public static void playTaskOrStop(Context context, IResponse<String> iResponse, boolean play, HostItemBean hostItemBean) {
        HashMap<String, Object> hasMap = new HashMap<>();
        hasMap.put("type", play ? HostModeListViewActivity.PRESIDE_SERVLET_TYPE_NODE_START : HostModeListViewActivity.PRESIDE_SERVLET_TYPE_NODE_STOP);
        hasMap.put("data", play ? JSON.toJSONString(hostItemBean) : "stop");
        OkHttpUtils.post("http://" + IpMsgConst.CHEST_SOCKET_HOST + ":7755/" + "presenterNewMsg", hasMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (iResponse != null) {
                    iResponse.onSucusse(result);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    public static void stop(Context context) {
        HashMap<String, Object> hasMap = new HashMap<>();
        hasMap.put("type", HostModeListViewActivity.PRESIDE_SERVLET_TYPE_NODE_STOP);
        hasMap.put("data", "stop");
        OkHttpUtils.post("http://" + IpMsgConst.CHEST_SOCKET_HOST + ":7755/" + "presenterNewMsg", hasMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {

            }

            @Override
            public void onFailure() {

            }
        });
    }

    private static void saveTaskData(Context context, IResponse<String> iResponse, HostModuleData hostModuleData, int type) {
        HashMap<String, Object> hasMap = new HashMap<>();
        hasMap.put("type", type);
        hasMap.put("data", JSON.toJSONString(hostModuleData));
        OkHttpUtils.post("http://" + IpMsgConst.CHEST_SOCKET_HOST + ":7755/" + "presenterNewMsg", hasMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (iResponse != null) {
                    iResponse.onSucusse(result);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getApplicationContext().getString(R.string.service_error_hint));
                }
            }
        });
    }

    public static void updateRecordFile(Context context, IResponse<AudioEvent> iResponse, final AudioEvent data) {
        String url = IpMsgConst.HTTP_URL + "uploadRecord";
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("audiofile", new File(UsherModeRecordDialog.RECORD_FILE_DIR, data.getMusicName()));
        hashMap.put("path", data.getMusicName());
        hashMap.put("dialog", "dialog");
        OkHttpUtils.post(url, hashMap, 100, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (iResponse != null) {
                    iResponse.onSucusse(data);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.update_error));
                }
            }
        });
    }

    public static void renameOneTask(Context context, IResponse<String> iResponse, String newName, String oldName) {
        HashMap<String, Object> hasMap = new HashMap<>();
        hasMap.put("type", PRESIDE_SERVLET_TYPE_RENAME);
        hasMap.put("oldName", oldName);
        hasMap.put("newName", newName);
        OkHttpUtils.post(IpMsgConst.HTTP_URL_CHEST + "presenterNewMsg", hasMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (iResponse != null) {
                    iResponse.onSucusse(result);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    public static void delelteOneTask(Context context, IResponse<String> iResponse, HostModuleData hostModuleData) {
        HashMap<String, Object> hasMap = new HashMap<>();
        hasMap.put("type", PRESIDE_SERVLET_TYPE_DELETE);
        hasMap.put("data", hostModuleData.getTaskName());
        OkHttpUtils.post(IpMsgConst.HTTP_URL_CHEST + "presenterNewMsg", hasMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                if (iResponse != null) {
                    iResponse.onSucusse(result);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    /**
     * 从pad加载所有的主持任务
     *
     * @param context
     * @param iResponse
     */
    public static void loadAllTask(Context context, IResponse<List<HostModuleData>> iResponse) {
        HashMap<String, Object> hasMap = new HashMap<>();
        hasMap.put("type", PRESIDE_SERVLET_TYPE_QUERY_ALL);
        OkHttpUtils.post("http://" + IpMsgConst.CHEST_SOCKET_HOST + ":7755/" + "presenterNewMsg", hasMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                JsonResponse jsonResponse = JSON.parseObject(result, JsonResponse.class);
                if (jsonResponse.getRc() == 0) {
                    List<HostModuleData> presenterTasks = JSONArray.parseArray(jsonResponse.getMsg(), HostModuleData.class);
                    if (iResponse != null) {
                        iResponse.onSucusse(presenterTasks);
                    }
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getString(R.string.service_error_hint));
                }
            }
        });
    }

    private static final String TAG = "NetLoadUtil";

    public static void loadAudio(Context context, IResponse<List<Audio>> iResponse) {
        String url = "http://" + IpMsgConst.HEAD_SOCKET_HOST + ":7755/getAudioList";
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("path", "/uusound");
        OkHttpUtils.upLoadFile(url, hashMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                JsonResponse strMsgBean = JSON.parseObject(result, JsonResponse.class);
                final List<Audio> datas = JSON.parseArray(strMsgBean.getResult().toString(), Audio.class);
                if (iResponse != null) {
                    iResponse.onSucusse(datas);
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getApplicationContext().getString(R.string.service_error_hint));
                }
            }
        });
    }

    public static void loadPicture(Context context, IResponse<String[]> iResponse) {
        String url = IpMsgConst.HTTP_URL_CHEST + "getAllPic";
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("path", "/uupic");
        OkHttpUtils.post(url, hashMap, new OkHttpUtils.OkHttpCallBack() {
            @Override
            public void onSuccess(String result) {
                JsonResponse jsonResponse = new Gson().fromJson(result, JsonResponse.class);
                if (jsonResponse != null) {
                    if (jsonResponse.getRc() == -1) {
                        if (iResponse != null) {
                            iResponse.onFailuer(context.getApplicationContext().getString(R.string.request_parameter_error));
                        }
                        return;
                    }
                    Type type = new TypeToken<String[]>() {
                    }.getType();
                    String[] picPaths = new Gson().fromJson(jsonResponse.getResult().toString(), type);
                    if (picPaths == null || picPaths.length == 0) {
                        if (iResponse != null) {
                            iResponse.onFailuer(context.getApplicationContext().getString(R.string.no_optional_background));
                        }
                    } else {
                        if (iResponse != null) {
                            iResponse.onSucusse(picPaths);
                        }
                    }
                } else {
                    if (iResponse != null) {
                        iResponse.onFailuer(context.getApplicationContext().getString(R.string.request_parameter_error));
                    }
                }
            }

            @Override
            public void onFailure() {
                if (iResponse != null) {
                    iResponse.onFailuer(context.getApplicationContext().getString(R.string.network_error));
                }
            }
        });
    }
}
